﻿#include "EquationSolver.h"
using namespace std;

class F1 : public Function
{
public:
    double operator()(double x)
    {
        return sin(x / 2) - 1;
    }
};

class F2 : public Function
{
public:
    double operator()(double x)
    {  
        return exp(x) - tan(x);
    }
};

class F3 : public Function
{
public:
    double operator()(double x)
    {
      
        return pow(x, 3) - 12 * pow(x, 2) + 3 * x + 1;
    }
};

int main() {
    cout << "-----------TestD----------" << endl;
    F1 func1;
    F2 func2;
    F3 func3;
    SecantSolver s1(0, M_PI / 2, eps, 50, func1);
    SecantSolver s11(M_PI / 4, 3 * M_PI / 4, eps, 50, func1);
    SecantSolver s2(1, 1.4, eps, 50, func2);
    SecantSolver s22(1.5, 2, eps, 50, func2);
    SecantSolver s3(0, -0.5, eps, 50, func3);
    SecantSolver s33(-0.2, 0.4, eps, 50, func3);
    cout << "Function1:   " << "root1 = " << s1.solve() << "   " << "root2 = " << s11.solve() << endl;
    cout << "Function1:   " << "f(root1) = " << func1(s1.solve()) << "   " << "root2 = " << func1(s11.solve()) << endl;
    cout << endl;
    cout << endl;
    cout << "Function2:   " << "root1 = " << s2.solve() << "   " << "root2 = " << s22.solve() << endl;
    cout << "Function2:   " << "f(root1) = " << func2(s2.solve()) << "   " << "root2 = " << func2(s22.solve()) << endl;
    cout << endl;
    cout << endl;
    cout << "Function3:   " << "root1 = " << s3.solve() << "   " << "root2 = " << s33.solve() << endl;
    cout << "Function3:   " << "f(root1) = " << func1(s3.solve()) << "   " << "root2 = " << func3(s33.solve()) << endl;


    
    return 0;
}